/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package com.aionemu.gameserver.model.gameobjects.knownList;

import java.util.Map;

import com.aionemu.commons.utils.SingletonMap;
import com.aionemu.gameserver.model.gameobjects.Creature;
import com.aionemu.gameserver.model.gameobjects.VisibleObject;

/**
 * @author Mr. Poke
 *
 */
public class AgressivNPCKnownList extends KnownList
{
	private final Map<Integer, Creature>			knownAgressiveTo		= new SingletonMap<Integer, Creature>().shared();

	/**
	 * @param owner
	 */
	public AgressivNPCKnownList(Creature owner)
	{
		super(owner);
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.knownList.KnownList#getOwner()
	 */
	@Override
	public Creature getOwner()
	{
		return (Creature) super.getOwner();
	}
	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.knownList.KnownList#addKnownObject(com.aionemu.gameserver.model.gameobjects.VisibleObject)
	 */
	@Override
	protected boolean addKnownObject(VisibleObject object)
	{
		if (super.addKnownObject(object))
		{
			if (object instanceof Creature && getOwner().isAggroTo(((Creature)object)))
			{
				knownAgressiveTo.put(object.getObjectId(), (Creature)object);
			}
			return true;
		}
		return false;
	}
	
	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.knownList.KnownList#clearKnownList()
	 */
	@Override
	public void clearKnownList()
	{
		super.clearKnownList();
		knownAgressiveTo.clear();
	}
	
	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.gameobjects.knownList.KnownList#removeKnownObject(com.aionemu.gameserver.model.gameobjects.VisibleObject, boolean)
	 */
	@Override
	protected boolean removeKnownObject(VisibleObject object, boolean isOutOfRange)
	{
		if (super.removeKnownObject(object, isOutOfRange))
		{
			knownAgressiveTo.remove(object.getObjectId());
			return true;
		}
		return false;
	}
	
	/**
	 * @return Returns the knownAgressiveTo.
	 */
	@Override
	public Map<Integer, Creature> getKnownAgressiveTo()
	{
		return knownAgressiveTo;
	}
}
